package com.lds.memory.kafka.topic;

import com.lds.memory.kafka.broker.status.Status;
import com.lds.memory.kafka.partition.Partition;

import java.util.List;

public class Topic implements Status {
    private final String name;

    private final List<Partition> partitions;

    public Topic(String name, List<Partition> partitions) {
        this.name = name;
        this.partitions = partitions;
    }

    public String getName() {
        return name;
    }


    public List<Partition> getPartitions() {
        return partitions;
    }

    @Override
    public void start() {
        for (Partition partition : partitions) {
            partition.start();
        }
    }

    @Override
    public void pause() {
        for (Partition partition : partitions) {
            partition.pause();
        }
    }

    @Override
    public void cancelPause() {
        for (Partition partition : partitions) {
            partition.cancelPause();
        }
    }

    @Override
    public void shutdown() {
        for (Partition partition : partitions) {
            partition.shutdown();
        }
    }
}
